Sure, here are the steps to integrate the PayUmoney payment gateway in CodeIgniter 3:
In your controller, create a new function for handling the payment process:
public function process_payment() {
// Load the PayUmoney library
$this->load->library('payumoney');
// Set payment parameters
$this->payumoney->amount = 10; // Replace with the actual amount
$this->payumoney->product_info = 'Test product'; // Replace with the actual product information
$this->payumoney->first_name = 'John'; // Replace with the buyer's first name
$this->payumoney->email = 'john@example.com'; // Replace with the buyer's email
// Generate the payment form
$this->payumoney->generate_form();
}
In your view, create a new file for displaying the payment form:
<form method="post" action="https://test.payu.in/_payment">
<!-- Hidden fields -->
<input type="hidden" name="key" value="<?php echo $key; ?>">
<input type="hidden" name="hash" value="<?php echo $hash; ?>">
<input type="hidden" name="txnid" value="<?php echo $txnid; ?>">
<!-- Payment details -->
<input type="hidden" name="amount" value="<?php echo $amount; ?>">
<input type="hidden" name="firstname" value="<?php echo $first_name; ?>">
<input type="hidden" name="email" value="<?php echo $email; ?>">
<input type="hidden" name="phone" value="<?php echo $phone; ?>">
<input type="hidden" name="productinfo" value="<?php echo $product_info; ?>">
<!-- Submit button -->
<input type="submit" value="Pay with PayUmoney">
</form>
In your library folder, create a new file for the PayUmoney library:
defined('BASEPATH') OR exit('No direct script access allowed');
class Payumoney {
public $amount;
public $product_info;
public $first_name;
public $email;
public function generate_form() {
// Set PayUmoney parameters
$key = 'YOUR_KEY'; // Replace with your PayUmoney key
$salt = 'YOUR_SALT'; // Replace with your PayUmoney salt
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
// Calculate hash
$hash_string = $key . '|' . $txnid . '|' . $this->amount . '|' . $this->product_info . '|' . $this->first_name . '|' . $this->email . '|||||||||||' . $salt;
$hash = strtolower(hash('sha512', $hash_string));
// Pass variables to the view
$data = array(
'key' => $key,
'hash' => $hash,
'txnid' => $txnid,
'amount' => $this->amount,
'first_name' => $this->first_name,
'email' => $this->email,
'product_info' => $this->product_info,
);
$this->load->view('payment_form', $data);
}
}
Note: Replace YOUR_KEY and YOUR_SALT with the actual key and salt provided by PayUmoney.
My name is Deepak tailor as a fullstack developer. I have been in the IT industry (PHP, Nodejs, flutter) for the last 5 years. For professional and customize web development & app development, you can send inquiry on our email.
----
You can contact him at deepaktailor10@yahoo.in